{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "from datetime import date\n",
    "from gs_quant.markets.position_set import PositionSet\n",
    "from gs_quant.session import Environment, GsSession"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "client = 'CLIENT ID'\n",
    "secret = 'CLIENT SECRET'\n",
    "\n",
    "GsSession.use(Environment.PROD, client_id=client, client_secret=secret, scopes=('read_product_data',))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Your excel file must be formatted in one of three ways (column names included). The third example will assign each position equal weight.\n",
    "<table>\n",
    "<tr><th>1. Position Weight</th><th>2. Position Quantity</th><th>3. Position Identifiers</th></tr>\n",
    "<tr><td>\n",
    "    <table>\n",
    "        <th>identifier</th><th>weight</th>\n",
    "        <tr>\n",
    "            <td>AAPL UW</td>\n",
    "            <td>0.4</td>\n",
    "        </tr>\n",
    "        <tr>\n",
    "            <td>MSFT UW</td>\n",
    "            <td>0.6</td>\n",
    "        </tr>\n",
    "        <tr></tr>\n",
    "    </table>\n",
    "</td><td>\n",
    "    <table>\n",
    "        <th>identifier</th><th>quantity</th>\n",
    "        <tr>\n",
    "            <td>AAPL UW</td>\n",
    "            <td>100</td>\n",
    "        </tr>\n",
    "        <tr>\n",
    "            <td>MSFT UW</td>\n",
    "            <td>100</td>\n",
    "        </tr>\n",
    "        <tr></tr>\n",
    "    </table>\n",
    "</td><td>\n",
    "    <table>\n",
    "        <th>identifier</th>\n",
    "        <tr>\n",
    "            <td>AAPL UW</td>\n",
    "        </tr>\n",
    "        <tr>\n",
    "            <td>MSFT UW</td>\n",
    "        </tr>\n",
    "        <tr></tr>\n",
    "    </table>\n",
    "</td></tr> </table>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "positions_df = pd.read_excel('positions_data.xlsx') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "position_set = PositionSet.from_frame(positions_df)\n",
    "position_set.resolve()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}